package com.dex4d.ui.mine.activity;

import android.graphics.Bitmap;
import android.text.TextUtils;
import android.widget.Button;

import com.dex4d.BuildConfig;
import com.dex4d.R;
import com.dex4d.model.User;
import com.dex4d.ui.wallet.activity.WalletReceiveActivity;
import com.king.zxing.util.CodeUtils;

import butterknife.BindView;

/**
 * Created by chengyuchun on 2018/12/7.
 */
public class DisplayReferralCodeActivity extends WalletReceiveActivity {

    @BindView(R.id.btn_copy)
    Button btn_copy;

    @Override
    protected void initToolbar() {
        showBackView();
        showTitle(getString(R.string.referral_code));
    }

    @Override
    protected void initVariables() {
        super.initVariables();
        btn_copy.setText(getString(R.string.copy_link));
    }

    @Override
    protected void loadData() {
        String url = BuildConfig.DAPP_HOME;
        if(TextUtils.isEmpty(User.getInstance().getMyReferralAlias())){
            url = url + "/" + User.getInstance().getAddress();
        }else {
            url = url + "/" + User.getInstance().getMyReferralAlias();
        }
        Bitmap bitmap = CodeUtils.createQRCode(url, getScreenWidth()/2);
        mImgQrCode.setImageBitmap(bitmap);

        tv_receive_address.setText(url);
    }
}
